
{% extends 'TopxiaAdminBundle::layout.html.twig' %} 

{% set menu = 'admin_course_learningcard'  %}

{% block main %}
{{ web_macro.flash_messages() }}

<form novalidate="" method="get" action="/admin/learningcard/build" class="form-inline" >
      <div class="form-group">
        <input type="text" value="" name="num" placeholder="数量" required class="form-control" style="max-width:80px;">
      </div>
      <div class="form-group">
        <input type="text" value="" name="usetime" placeholder="充值有效期（月）" required class="form-control" style="max-width:135px;">
      </div>
       <div class="form-group">
        <input type="text" value="" name="valid" placeholder="充值后使用有效期（月）" required class="form-control" style="max-width:175px;">
      </div>
      <div class="form-group">
        <input type="text" value="" name="money" placeholder="面额" required class="form-control" style="max-width:60px;">
      </div>
      <div class="form-group">
        <input type="text" value="" name="title" placeholder="学习卡名称" required class="form-control" style="max-width:100px;">
      </div>
      <div class="form-group">
        <select name="type" class="form-control" style="max-width:150px;">
          <option value="">学习卡类型</option>
            <option value="book">book</option>
            <option value="card">card</option>
        </select>
      </div>
       <div class="form-group">
        <select name="cateId" class="form-control" style="max-width:150px;">
          <option >适用范围</option>
          <option value="0">通用</option>

          {% for re in res %}
          <option value="{{ re.id }}">{{ re.name }}</option>
          {% endfor %}
        </select>
          
      </div>
      <div class="form-group">
        <select name="category" class="form-control" style="max-width:150px;">
          <option value="">学习卡分类</option>
            <option value="0">通用</option>
            <option value="1">班级</option>
            <option value="3">视频课程</option>
          <option value="6">考试题库</option>  
        </select>
      </div>
      <div class="form-group">
        <input type="text"  name="batch" readonly  value="{{ (maxbatch+1)|default(1) }}" required="required" class="form-control" style="max-width:50px;">

      </div>

           <button class="btn btn-primary">生成学习卡</button>
    <span class="btn btn-primary">现已有<span style="color:red;font-size:16px;"> {{ maxbatch|default(0) }} </span>批次</span>
          
    </form>
<div class="well well-sm mtl">
    <form novalidate="" method="get" action="/admin/learningcard/searchId" class="form-inline" id="activema-search-form">
      <div class="form-group">
        <input type="text" value="" name="cardId" placeholder="学习卡号" class="form-control" style="max-width:200px;" required> 
        <input type="text" value="" name="batch" placeholder="批次" class="form-control" style="max-width:60px;" required>
      </div>
      <button class="btn btn-primary">搜索</button>

    </form>
</div>


<table class="table table-hover" id="category-table">
  <thead>
    <tr>
      <th width="30px">ID</th>
      <th width="30px">批次</th>
      <th >卡号</th>
      <th>标题</th>
      <th width="50px">适用范围ID</th>
      <th>充值有效期</th>
      <th>充值后有效期</th>
      <th >状态</th>
      <th >面额</th>
      <th>分类</th>
      <th>类别</th>
      <th>充值者ID</th>
      <th>充值日期</th>
      <th >操作</th>
    </tr>
  </thead>


  {% for card in card%}
    <tr>
      <td>{{ card.id }}</td>
      <td>{{ card.batch }}</td>
      <td>{{ card.cardId }}</td>
      <td>{{ card.title }}</td>
      <td>{{ card.cateId }}</td>
      <td>
      {% if card.usetime == '0' %}
      永久
      {% else %}

      {{ card.usetime|date('Y-m-d') }}
      {% endif %}
      </td>
      <td>{{ card.valid }}个月</td>
      <td>
        {% if card.status == '0' %}<span style="color:green;">未充值</span>{% endif %}
        {% if card.status == '1' %}<span style="color:red;">已充值</span>/<span style="color:green;">未使用</span>{% endif %}
        {% if card.status == '2' %}<span style="color:black;">未充值过期</span>{% endif %}
        {% if card.status == '3' %}<span style="color:black;">已充值/已使用</span>{% endif %}
        {% if card.status == '4' %}<span style="color:black;">已充值/已过期</span>{% endif %}
       



      </td>
      <td>{{ card.money }}</td>
      <td>
        {% if card.category == '0' %} <span style="color:#C598D9;">通用 {% endif %}
        {% if card.category == '1' %} <span style="color:#C598D9;">班级 {% endif %}
        {% if card.category == '3' %} <span style="color:#C598D9;">视频课程 {% endif %}
        {% if card.category == '6' %} <span style="color:blue;">考试题库</span> {% endif %} 
      </td>
      <td>
      {% if card.type == 'card'  %}
      <span style="color:blue">{{ card.type }}</span>
      {% else %}
      <span style="color:green">{{ card.type }}</span>
      {% endif %}
      </td>
      <td>
      {% if card.userId == "0" %}
      暂无
      {% else %}
      {{ card.userId }}

      {% endif %}

      </td>
      <td>
       {% if card.rechargetime == "0" %}
      暂无
      {% else %}
      {{ card.rechargetime|date('Y-m-d H:i:s') }}

      {% endif %}
      <td><a class="btn btn-default btn-sm "  href="{{ path('admin_learningcard_delete', {id:card.id}) }}"><i class="glyphicon glyphicon-trash"></i >&nbsp;&nbsp;删除</a></td>

    
    </tr>

  {% endfor %}

</table> 

{{ web_macro.paginator(paginator) }}
{% endblock %}